
package com.hlkj.pay.vo.order.resp.export;
/*
 * Hlpay-Plus aggregate payment system.
 * Copyright (c) 2024-2025 Hlpay Team Copyright has the right of final interpretation.
 */

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;

/**
 * @author HlpayTeam
 * @date 2024/10/09 11:37
 */
@Data
public class StatisticsAgentFileExport {

    /**
     * 备注
     */
    @Schema(description = "商户sn")
    @ExcelProperty("机构编号")
    @ColumnWidth(20)
    private String sn;

    /**
     * 备注
     */
    @Schema(description = "商户sn")
    @ExcelProperty("机构名称")
    @ColumnWidth(20)
    private String agentName;

    /**
     * 订单笔数
     */
    @Schema(description = "订单笔数")
    @ExcelProperty("订单笔数")
    @ColumnWidth(20)
    private Integer submitOrderCount;

    /**
     * 支付订单笔数
     */
    @Schema(description = "支付订单笔数")
    @ExcelProperty("支付订单笔数")
    @ColumnWidth(20)
    private Integer payOrderCount;

    /**
     * 订单金额
     */
    @Schema(description = "订单金额")
    @ExcelProperty("订单金额")
    @ColumnWidth(20)
    private BigDecimal submitOrderAmount;

    /**
     * 支付订单金额
     */
    @Schema(description = "支付订单金额")
    @ExcelProperty("支付订单金额")
    @ColumnWidth(20)
    private BigDecimal payOrderAmount;

    /**
     * 退款笔数
     */
    @Schema(description = "退款笔数")
    @ExcelProperty("退款笔数")
    @ColumnWidth(20)
    private Integer refundCount;

    /**
     * 退款金额
     */
    @Schema(description = "退款金额")
    @ExcelProperty("退款金额")
    @ColumnWidth(20)
    private BigDecimal refundAmount;

    /**
     * 平台交易手续费
     */
    @Schema(description = "平台交易手续费")
    @ExcelProperty("平台交易手续费")
    @ColumnWidth(20)
    private BigDecimal feeAmount;

    /**
     * 机构交易手续费
     */
    @Schema(description = "机构交易手续费")
    @ExcelProperty("机构交易手续费")
    @ColumnWidth(20)
    private BigDecimal channelFeeAmount;

    /**
     * 充值金额
     */
    @Schema(description = "充值金额")
    @ExcelProperty("充值金额")
    @ColumnWidth(20)
    private BigDecimal chargeAmount;
    /**
     * 投诉订单数
     */
    @Schema(description = "投诉订单数")
    @ExcelProperty("投诉订单数")
    @ColumnWidth(20)
    private Integer complainCount;

    @ExcelProperty("成功率")
    @ColumnWidth(20)
    private String successRate;

    public String getSuccessRate() {
        if (submitOrderCount != null && submitOrderCount > 0 && payOrderCount != null) {
            // 计算成功率并格式化为百分比，保留两位小数
            double rate = (double) payOrderCount / submitOrderCount * 100;
            return String.format("%.2f%%", rate);
        }
        return "0%"; // 如果提交订单数为0或为空，返回0%
    }
}
